#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
	ll a,b,m;
	cin >> a >> b >> m;
	ll ans = 0;
	cout << m/a + m/b + 2 << "\n";
}
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int t = 1;
	cin >> t;
	while(t--) solve();
}